﻿using System;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ID;
using Terraria.Localization;

namespace Terraria.ModLoader
{
	// Token: 0x020001E9 RID: 489
	public class ModNPC
	{
		// Token: 0x1700017E RID: 382
		// (get) Token: 0x06001477 RID: 5239 RVA: 0x000104D2 File Offset: 0x0000E6D2
		// (set) Token: 0x06001478 RID: 5240 RVA: 0x000104DA File Offset: 0x0000E6DA
		public NPC npc { get; internal set; }

		// Token: 0x1700017F RID: 383
		// (get) Token: 0x06001479 RID: 5241 RVA: 0x000104E3 File Offset: 0x0000E6E3
		// (set) Token: 0x0600147A RID: 5242 RVA: 0x000104EB File Offset: 0x0000E6EB
		public Mod mod { get; internal set; }

		// Token: 0x17000180 RID: 384
		// (get) Token: 0x0600147B RID: 5243 RVA: 0x000104F4 File Offset: 0x0000E6F4
		// (set) Token: 0x0600147C RID: 5244 RVA: 0x000104FC File Offset: 0x0000E6FC
		public string Name { get; internal set; }

		// Token: 0x17000181 RID: 385
		// (get) Token: 0x0600147D RID: 5245 RVA: 0x00010505 File Offset: 0x0000E705
		// (set) Token: 0x0600147E RID: 5246 RVA: 0x0001050D File Offset: 0x0000E70D
		public ModTranslation DisplayName { get; internal set; }

		// Token: 0x17000182 RID: 386
		// (get) Token: 0x0600147F RID: 5247 RVA: 0x00010516 File Offset: 0x0000E716
		public virtual string Texture
		{
			get
			{
				return (base.GetType().Namespace + "." + this.Name).Replace('.', '/');
			}
		}

		// Token: 0x17000183 RID: 387
		// (get) Token: 0x06001480 RID: 5248 RVA: 0x0001053C File Offset: 0x0000E73C
		public virtual string[] AltTextures
		{
			get
			{
				return new string[0];
			}
		}

		// Token: 0x17000184 RID: 388
		// (get) Token: 0x06001481 RID: 5249 RVA: 0x00010544 File Offset: 0x0000E744
		public virtual string HeadTexture
		{
			get
			{
				return this.Texture + "_Head";
			}
		}

		// Token: 0x17000185 RID: 389
		// (get) Token: 0x06001482 RID: 5250 RVA: 0x00010556 File Offset: 0x0000E756
		public virtual string BossHeadTexture
		{
			get
			{
				return this.Texture + "_Head_Boss";
			}
		}

		// Token: 0x06001483 RID: 5251 RVA: 0x00010568 File Offset: 0x0000E768
		public ModNPC()
		{
			this.npc = new NPC();
			this.npc.modNPC = this;
		}

		// Token: 0x06001484 RID: 5252 RVA: 0x0001059C File Offset: 0x0000E79C
		public virtual bool Autoload(ref string name)
		{
			return this.mod.Properties.Autoload;
		}

		// Token: 0x06001485 RID: 5253 RVA: 0x00413860 File Offset: 0x00411A60
		internal void SetupNPC(NPC npc)
		{
			ModNPC modNPC = (ModNPC)(this.CloneNewInstances ? base.MemberwiseClone() : Activator.CreateInstance(base.GetType()));
			modNPC.npc = npc;
			npc.modNPC = modNPC;
			modNPC.mod = this.mod;
			modNPC.Name = this.Name;
			modNPC.SetDefaults();
		}

		// Token: 0x17000186 RID: 390
		// (get) Token: 0x06001486 RID: 5254 RVA: 0x0000ADF8 File Offset: 0x00008FF8
		public virtual bool CloneNewInstances
		{
			get
			{
				return false;
			}
		}

		// Token: 0x06001487 RID: 5255 RVA: 0x000105AE File Offset: 0x0000E7AE
		public virtual ModNPC Clone()
		{
			return (ModNPC)base.MemberwiseClone();
		}

		// Token: 0x06001488 RID: 5256 RVA: 0x004138BC File Offset: 0x00411ABC
		public virtual ModNPC NewInstance(NPC npcClone)
		{
			if (this.CloneNewInstances)
			{
				ModNPC modNPC = this.Clone();
				modNPC.npc = npcClone;
				return modNPC;
			}
			ModNPC modNPC2 = (ModNPC)Activator.CreateInstance(base.GetType());
			modNPC2.npc = npcClone;
			modNPC2.mod = this.mod;
			modNPC2.Name = this.Name;
			modNPC2.aiType = this.aiType;
			modNPC2.animationType = this.animationType;
			modNPC2.bossBag = this.bossBag;
			modNPC2.music = this.music;
			modNPC2.drawOffsetY = this.drawOffsetY;
			modNPC2.banner = this.banner;
			modNPC2.bannerItem = this.bannerItem;
			return modNPC2;
		}

		// Token: 0x06001489 RID: 5257 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void SetDefaults()
		{
		}

		// Token: 0x0600148A RID: 5258 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void SetStaticDefaults()
		{
		}

		// Token: 0x0600148B RID: 5259 RVA: 0x00413968 File Offset: 0x00411B68
		public virtual void AutoStaticDefaults()
		{
			Main.npcTexture[this.npc.type] = ModLoader.GetTexture(this.Texture);
			if (this.banner != 0 && this.bannerItem != 0)
			{
				NPCLoader.bannerToItem[this.banner] = this.bannerItem;
			}
			else if (this.banner != 0 || this.bannerItem != 0)
			{
				ErrorLogger.Log(Language.GetTextValue("tModLoader.LoadWarningBannerOrBannerItemNotSet", this.mod.DisplayName, this.Name));
			}
			if (this.npc.lifeMax > 32767 || this.npc.boss)
			{
				Main.npcLifeBytes[this.npc.type] = 4;
			}
			else if (this.npc.lifeMax > 127)
			{
				Main.npcLifeBytes[this.npc.type] = 2;
			}
			else
			{
				Main.npcLifeBytes[this.npc.type] = 1;
			}
			string[] altTextures = this.AltTextures;
			int num = altTextures.Length;
			NPCID.Sets.ExtraTextureCount[this.npc.type] = num;
			Main.npcAltTextures[this.npc.type] = new Texture2D[num + 1];
			if (num > 0)
			{
				Main.npcAltTextures[this.npc.type][0] = Main.npcTexture[this.npc.type];
			}
			for (int i = 1; i <= num; i++)
			{
				Main.npcAltTextures[this.npc.type][i] = ModLoader.GetTexture(altTextures[i - 1]);
			}
			if (this.DisplayName.IsDefault())
			{
				this.DisplayName.SetDefault(Regex.Replace(this.Name, "([A-Z])", " $1").Trim());
			}
		}

		// Token: 0x0600148C RID: 5260 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void ScaleExpertStats(int numPlayers, float bossLifeScale)
		{
		}

		// Token: 0x0600148D RID: 5261 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void ResetEffects()
		{
		}

		// Token: 0x0600148E RID: 5262 RVA: 0x00008CF7 File Offset: 0x00006EF7
		public virtual bool PreAI()
		{
			return true;
		}

		// Token: 0x0600148F RID: 5263 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void AI()
		{
		}

		// Token: 0x06001490 RID: 5264 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void PostAI()
		{
		}

		// Token: 0x06001491 RID: 5265 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void SendExtraAI(BinaryWriter writer)
		{
		}

		// Token: 0x06001492 RID: 5266 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void ReceiveExtraAI(BinaryReader reader)
		{
		}

		// Token: 0x06001493 RID: 5267 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void FindFrame(int frameHeight)
		{
		}

		// Token: 0x06001494 RID: 5268 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void HitEffect(int hitDirection, double damage)
		{
		}

		// Token: 0x06001495 RID: 5269 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void UpdateLifeRegen(ref int damage)
		{
		}

		// Token: 0x06001496 RID: 5270 RVA: 0x00008CF7 File Offset: 0x00006EF7
		public virtual bool CheckActive()
		{
			return true;
		}

		// Token: 0x06001497 RID: 5271 RVA: 0x00008CF7 File Offset: 0x00006EF7
		public virtual bool CheckDead()
		{
			return true;
		}

		// Token: 0x06001498 RID: 5272 RVA: 0x0000ADF8 File Offset: 0x00008FF8
		public virtual bool SpecialNPCLoot()
		{
			return false;
		}

		// Token: 0x06001499 RID: 5273 RVA: 0x00008CF7 File Offset: 0x00006EF7
		public virtual bool PreNPCLoot()
		{
			return true;
		}

		// Token: 0x0600149A RID: 5274 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void NPCLoot()
		{
		}

		// Token: 0x0600149B RID: 5275 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void BossLoot(ref string name, ref int potionType)
		{
		}

		// Token: 0x0600149C RID: 5276 RVA: 0x00008CF7 File Offset: 0x00006EF7
		public virtual bool CanHitPlayer(Player target, ref int cooldownSlot)
		{
			return true;
		}

		// Token: 0x0600149D RID: 5277 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void ModifyHitPlayer(Player target, ref int damage, ref bool crit)
		{
		}

		// Token: 0x0600149E RID: 5278 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void OnHitPlayer(Player target, int damage, bool crit)
		{
		}

		// Token: 0x0600149F RID: 5279 RVA: 0x00404F84 File Offset: 0x00403184
		public virtual bool? CanHitNPC(NPC target)
		{
			return null;
		}

		// Token: 0x060014A0 RID: 5280 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit)
		{
		}

		// Token: 0x060014A1 RID: 5281 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void OnHitNPC(NPC target, int damage, float knockback, bool crit)
		{
		}

		// Token: 0x060014A2 RID: 5282 RVA: 0x00404F84 File Offset: 0x00403184
		public virtual bool? CanBeHitByItem(Player player, Item item)
		{
			return null;
		}

		// Token: 0x060014A3 RID: 5283 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void ModifyHitByItem(Player player, Item item, ref int damage, ref float knockback, ref bool crit)
		{
		}

		// Token: 0x060014A4 RID: 5284 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void OnHitByItem(Player player, Item item, int damage, float knockback, bool crit)
		{
		}

		// Token: 0x060014A5 RID: 5285 RVA: 0x00404F84 File Offset: 0x00403184
		public virtual bool? CanBeHitByProjectile(Projectile projectile)
		{
			return null;
		}

		// Token: 0x060014A6 RID: 5286 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
		{
		}

		// Token: 0x060014A7 RID: 5287 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit)
		{
		}

		// Token: 0x060014A8 RID: 5288 RVA: 0x00008CF7 File Offset: 0x00006EF7
		public virtual bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit)
		{
			return true;
		}

		// Token: 0x060014A9 RID: 5289 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void BossHeadSlot(ref int index)
		{
		}

		// Token: 0x060014AA RID: 5290 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void BossHeadRotation(ref float rotation)
		{
		}

		// Token: 0x060014AB RID: 5291 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void BossHeadSpriteEffects(ref SpriteEffects spriteEffects)
		{
		}

		// Token: 0x060014AC RID: 5292 RVA: 0x00404FFC File Offset: 0x004031FC
		public virtual Color? GetAlpha(Color drawColor)
		{
			return null;
		}

		// Token: 0x060014AD RID: 5293 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void DrawEffects(ref Color drawColor)
		{
		}

		// Token: 0x060014AE RID: 5294 RVA: 0x00008CF7 File Offset: 0x00006EF7
		public virtual bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
		{
			return true;
		}

		// Token: 0x060014AF RID: 5295 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void PostDraw(SpriteBatch spriteBatch, Color drawColor)
		{
		}

		// Token: 0x060014B0 RID: 5296 RVA: 0x00404F84 File Offset: 0x00403184
		public virtual bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
		{
			return null;
		}

		// Token: 0x060014B1 RID: 5297 RVA: 0x000105BB File Offset: 0x0000E7BB
		public virtual float SpawnChance(NPCSpawnInfo spawnInfo)
		{
			return 0f;
		}

		// Token: 0x060014B2 RID: 5298 RVA: 0x00413B18 File Offset: 0x00411D18
		public virtual int SpawnNPC(int tileX, int tileY)
		{
			return NPC.NewNPC(tileX * 16 + 8, tileY * 16, this.npc.type, 0, 0f, 0f, 0f, 0f, 255);
		}

		// Token: 0x060014B3 RID: 5299 RVA: 0x0000ADF8 File Offset: 0x00008FF8
		public virtual bool CanTownNPCSpawn(int numTownNPCs, int money)
		{
			return false;
		}

		// Token: 0x060014B4 RID: 5300 RVA: 0x00008CF7 File Offset: 0x00006EF7
		public virtual bool CheckConditions(int left, int right, int top, int bottom)
		{
			return true;
		}

		// Token: 0x060014B5 RID: 5301 RVA: 0x000105C2 File Offset: 0x0000E7C2
		public virtual string TownNPCName()
		{
			return Language.GetTextValue("tModLoader.DefaultTownNPCName");
		}

		// Token: 0x060014B6 RID: 5302 RVA: 0x00008CF7 File Offset: 0x00006EF7
		public virtual bool UsesPartyHat()
		{
			return true;
		}

		// Token: 0x060014B7 RID: 5303 RVA: 0x000105CE File Offset: 0x0000E7CE
		public virtual string GetChat()
		{
			return Language.GetTextValue("tModLoader.DefaultTownNPCChat");
		}

		// Token: 0x060014B8 RID: 5304 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void SetChatButtons(ref string button, ref string button2)
		{
		}

		// Token: 0x060014B9 RID: 5305 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void OnChatButtonClicked(bool firstButton, ref bool shop)
		{
		}

		// Token: 0x060014BA RID: 5306 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void SetupShop(Chest shop, ref int nextSlot)
		{
		}

		// Token: 0x060014BB RID: 5307 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void TownNPCAttackStrength(ref int damage, ref float knockback)
		{
		}

		// Token: 0x060014BC RID: 5308 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown)
		{
		}

		// Token: 0x060014BD RID: 5309 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void TownNPCAttackProj(ref int projType, ref int attackDelay)
		{
		}

		// Token: 0x060014BE RID: 5310 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)
		{
		}

		// Token: 0x060014BF RID: 5311 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void TownNPCAttackShoot(ref bool inBetweenShots)
		{
		}

		// Token: 0x060014C0 RID: 5312 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void TownNPCAttackMagic(ref float auraLightMultiplier)
		{
		}

		// Token: 0x060014C1 RID: 5313 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void TownNPCAttackSwing(ref int itemWidth, ref int itemHeight)
		{
		}

		// Token: 0x060014C2 RID: 5314 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void DrawTownAttackGun(ref float scale, ref int item, ref int closeness)
		{
		}

		// Token: 0x060014C3 RID: 5315 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void DrawTownAttackSwing(ref Texture2D item, ref int itemSize, ref float scale, ref Vector2 offset)
		{
		}

		// Token: 0x040014CA RID: 5322
		public int aiType;

		// Token: 0x040014CB RID: 5323
		public int animationType;

		// Token: 0x040014CC RID: 5324
		public int bossBag = -1;

		// Token: 0x040014CD RID: 5325
		public int music = -1;

		// Token: 0x040014CE RID: 5326
		public MusicPriority musicPriority = MusicPriority.BossLow;

		// Token: 0x040014CF RID: 5327
		public float drawOffsetY;

		// Token: 0x040014D0 RID: 5328
		public int banner;

		// Token: 0x040014D1 RID: 5329
		public int bannerItem;
	}
}
